package com.freecloud.javabasics.design.memento.demo1;

/**
 * @Author: maomao
 * @Date: 2020-03-18 22:03
 */
public class Editor {

    private String title;
    private String content;

    public Editor(String title, String content) {
        this.title = title;
        this.content = content;
    }

    public ArticleMemento saveToMemento(){
        ArticleMemento articleMemento = new ArticleMemento(this.title,this.content);
        return articleMemento;
    }

    public void undoFromMemento(ArticleMemento articleMemento){
        this.title = articleMemento.getTitle();
        this.content = articleMemento.getContent();
    }

    @Override
    public String toString() {
        return "Editor{" +
                "title='" + title + '\'' +
                ", content='" + content + '\'' +
                '}';
    }
}
